Skip to content

Conversation

@skearya
Copy link

@skearya skearya commented Feb 22, 2024

In the channels section of the tutorial, a use statement imports all variants of the Command enum,

    while let Some(cmd) = rx.recv().await {
        use Command::*;

        match cmd {
            Get { key } => {
                client.get(&key).await;
            }
            Set { key, val } => {
                client.set(&key, val).await;
            }
        }
    }

This is bad practice because renaming / removing something in the Command enum doesn't cause a compile time error, like in a normal match statement, and creates a catch-all in the match.

Code_WJwujKAkVD.mp4

This PR just removes the use Command::* and changes the match statement to be on the full enum path in channels.md

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants